package cn.dlc.com.mapper;

import cn.dlc.com.pojo.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author deng
 * @date 2021/6/24 16:35
 **/
public interface SysUserMapper extends BaseMapper<SysUser> {


    @Select("select * from sys_user where username=#{username}")
    @Results({
            @Result(id=true,property = "id", column = "id"),
            @Result(property = "roles" ,column = "id", javaType = List.class,
                many = @Many(select = "cn.dlc.com.mapper.SysRoleMapper.findByUserId")
            )
    })
    SysUser findByName(String username);
}
